home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / XCEEDTOO.BAS < prev    next >
Encoding:
BASIC Source File  |  1999-04-26  |  17.3 KB  |  261 lines

  1. Attribute VB_Name = "XceedTools"
  2. '==================================================================
  3. ' Description: Module for Getting Started Sample Application
  4. ' Copyright:   ⌐ Copyright 1995-1999 Xceed Software Inc.
  5. '                All Rights Reserved.
  6. '==================================================================
  7.  
  8. Option Explicit
  9.  
  10.  
  11. '------------------------------------------------------------------------------------
  12. ' Public constants
  13. '------------------------------------------------------------------------------------
  14.     
  15.     Public Const cBasePathHint = "BasePath property:" & vbCrLf & _
  16.                                  "This path determines where entries in the FilesToProcess and FilesToExclude " & _
  17.                                  "properties are relative to. The base path never appears in the zip file, " & _
  18.                                  "even if PreservePaths = True. Only the portion of the path and filename specified " & _
  19.                                  "in the FilesToProcess property is actually stored in the zip file. Therefore, " & _
  20.                                  "BasePath helps you control what portions of paths are stored in the zip file. " & _
  21.                                  "(The BasePath property is irrelevant when you are using absolute paths)"
  22.                           
  23.     Public Const cFilesToProcessHint = "FilesToProcess property:" & vbCrLf & _
  24.                                 "Multiline string that contains all the filenames and/or file masks " & _
  25.                                 "to be processed (zipped, unzipped, etc). If you entered a path in the " & _
  26.                                 "BasePath property, all entries with relative paths will be relative to " & _
  27.                                 "the specified base path. The pipe character '|' can be used instead of the linefeed " & _
  28.                                 "to separate entries for the FilesToProcess property."
  29.     
  30.     Public Const cFilesToExcludeHint = "FilesToExclude property:" & vbCrLf & _
  31.                                 "Multiline string that contains all filenames and/or file masks " & _
  32.                                 "to exclude from the files to be processed by the FilesToProcess " & _
  33.                                 "property. These entries are also relative to the path specified in the " & _
  34.                                 "BasePath property if its not empty."
  35.                                 
  36.     Public Const cProcessSubfolderHint = "ProcessSubFolders property:" & vbCrLf & _
  37.                                   "If set to True, the contents of all encoutered subfolders will be " & _
  38.                                   "processed."
  39.     
  40.     Public Const cZipFilenameHint = "ZipFilename property:" & vbCrLf & _
  41.                              "The filename of the zip file to work with. When unzipping, this file must " & _
  42.                              "exist. When zipping, if the file exists, it's updated. Otherwise, it is " & _
  43.                              "created. You must enter an absolute path for this property. The BasePath " & _
  44.                              "property does not interfere with the ZipFilename property."
  45.  
  46.     Public Const cPreservePathsHint = "PreservePaths property:" & vbCrLf & _
  47.                                "If set to True, the zip file will store both the path and the filename " & _
  48.                                "of each file that is being zipped. As usual, the portion of a file's path that " & _
  49.                                "is specified in the BasePath property will not be stored in the zip file. " & _
  50.                                "When PreservePaths is set to False, only filenames (no paths) are stored."
  51.                                
  52.     Public Const cUseTempFileHint = "UseTempFile property:" & vbCrLf & _
  53.                              "If set to true, all zipping operations will be performed on a temp file " & _
  54.                              "located in the folder specified in the TempFolder property. Otherwise, the " & _
  55.                              "operation is performed directly on the zip file without using a temp file. " & _
  56.                              "You cannot remove files from an existing zip file, or update files already " & _
  57.                              "in an existing zip files without setting this property to True."
  58.                              
  59.     Public Const cTempFolderHint = "TempFolder property:" & vbCrLf & _
  60.                                    "Location of the temp file when the UseTempFile property is set to True. " & _
  61.                                    "When you leave this property empty, the Windows default temp directory " & _
  62.                                    "is used."
  63.                             
  64.     Public Const cRequiredFileAttributesHint = "RequiredFileAttributes property:" & vbCrLf & _
  65.                                                "Bit-field value that specifies all attributes that a file must " & _
  66.                                                "have in order to be included in the process."
  67.                                         
  68.     Public Const cExcludedFileAttributesHint = "ExcludedFileAttributes property:" & vbCrLf & _
  69.                                                "Bit-field value that specifies all attributes that a file must " & _
  70.                                                "NOT have in order to be included in the process."
  71.                                         
  72.     Public Const cMinDateToProcessHint = "MinDateToProcess property:" & vbCrLf & _
  73.                                          "Minimum value of a file's 'Last modifed date' required in order to be " & _
  74.                                          "included in the process."
  75.     
  76.     Public Const cMaxDateToProcessHint = "MaxDateToProcess property:" & vbCrLf & _
  77.                                          "Maximum value of a file's 'Last modifed date' required in order to be " & _
  78.                                          "included in the process."
  79.                                   
  80.     Public Const cMinSizeToProcessHint = "MinSizeToProcess property:" & vbCrLf & _
  81.                                          "Minimum file size that a file must have in order to be " & _
  82.                                          "included in the process."
  83.     
  84.     Public Const cMaxSizeToProcessHint = "MaxSizeToProcess property:" & vbCrLf & _
  85.                                          "Maximum file size that a file must have in order to be " & _
  86.                                          "included in the process."
  87.     
  88.     Public Const cUnzipToFolderHint = "UnzipToFolder property:" & vbCrLf & _
  89.                                       "Destination folder for files being unzipped. In this sample, the PreservePaths " & _
  90.                                       "property is set to True, so if files are stored in the zip file with paths, " & _
  91.                                       "those stored paths will be recreated inside the destination folder specified " & _
  92.                                       "by the UnzipToFolder property."
  93.     
  94.     Public Const cSkipIfExistingHint = "SkipIfExisting property:" & vbCrLf & _
  95.                                        "If the destination file (located in a zip file that is being updated, or " & _
  96.                                        "on disk when a zip file is being unzipped) already exists, and this " & _
  97.                                        "property is set to True, then the file won't be overwritten. This has the " & _
  98.                                        "effect of only processing files that don't exist in the destination zip file or " & _
  99.                                        "unzipping folder."
  100.                                 
  101.     Public Const cSkipIfNotExistingHint = "SkipIfNotExisting property:" & vbCrLf & _
  102.                                        "Setting this property to True will cause only files that don't already " & _
  103.                                        "exist in the destination unzipping location (when unzipping) or the zip file " & _
  104.                                        "(when zipping) to be skipped."
  105.                                    
  106.     Public Const cSkipIfOlderDateHint = "SkipIfOlderDate:" & vbCrLf & _
  107.                                         "When updating a file (in a zip file while zipping, or on disk while unzipping)" & _
  108.                                         ", the file is skipped if the existing file's 'Last modified date' is greater " & _
  109.                                         "than the file being zipped or unzipped."
  110.                                  
  111.     Public Const cSkipIfOlderVersionHint = "SkipIfOlderVersion property:" & vbCrLf & _
  112.                                            "When updating a file (in a zip while zipping, or on disk while unzipping)" & _
  113.                                            ", the file is skipped if the existing file's version resource value is " & _
  114.                                            "greater than the file being zipped or unzipped."
  115.                                     
  116.     Public Const cZipFilenameSfxHint = "ZipFilename property:" & vbCrLf & _
  117.                                        "The filename of the zip file to work on. When creating or updating self-extracting " & _
  118.                                        "zip files, you should enter an executable filename (use a .EXE extension)"
  119.                                 
  120.     Public Const cSfxBinaryModuleHint = "SfxBinaryModule property:" & vbCrLf & _
  121.                                         "This binary file will be prepended to the zip file, with configuration data " & _
  122.                                         "if the binary is one of the Xceed Self-Extractor Module binaries. If you " & _
  123.                                         "leave this field empty, a regular (non-sfx) zip file will be created."
  124.                                  
  125.     Public Const cSfxStringsHint = "SfxStrings property:" & vbCrLf & _
  126.                                    "This array contains all the strings displayed by the Xceed Self-Extractor Module " & _
  127.                                    "binaries. For example, the 'xssTitle' index contains the title displayed by " & _
  128.                                    "all dialog boxes."
  129.                             
  130.     Public Const cSfxMessagesHint = "SfxMessages property:" & vbCrLf & _
  131.                                     "This array contains all messages displayed by the Xceed Self-Extractor Module " & _
  132.                                     "binaries. These messages often appear in their own dialog boxes. If a particular " & _
  133.                                     "message is left empty, the dialog box won't be displayed. As an example, " & _
  134.                                     "leaving this field empty will avoid displaying an introduction message dialog."
  135.                              
  136.     Public Const cPreviewFilesHint = "PreviewFiles method:" & vbCrLf & _
  137.                                      "Lets you scan the disk for files that would be zipped with the current " & _
  138.                                      "property settings. A PreviewingFile event is triggered for each file that " & _
  139.                                      "matches an entry in the FilesToProcess property. Set this method's " & _
  140.                                      "parameter to True to have the library calculate the compressed size of " & _
  141.                                      "the previewed files."
  142.     
  143.     Public Const cListZipContentsHint = "ListZipContents method:" & vbCrLf & _
  144.                                         "Lets you view the zip file's contents. Due to the fact that the FilesToProcess " & _
  145.                                         "property and the other filtering properties affect the ListZipContents method, " & _
  146.                                         "you can use it to preview which files would be unzipped by the Unzip method " & _
  147.                                         "if it were called with the current property settings. A ListingFile event is " & _
  148.                                         "triggered for each file in the zip file that is listed."
  149.                                 
  150.     Public Const cZipHint = "Zip method:" & vbCrLf & _
  151.                             "Lets you zip files. Only files that match all the entries in the FilesToProcess and " & _
  152.                             "filtering properties will be processed. For each file that matches the FilesToProcess " & _
  153.                             "property, the ZipPreprocessingFile event is triggered. That event provides you with " & _
  154.                             "the chance to change the inclusion state of a file, or to change its information " & _
  155.                             "before it is stored in the zip file."
  156.     
  157.     Public Const cUnzipHint = "Unzip method:" & vbCrLf & _
  158.                             "Lets you unzip files. Only files that match all the entries in the FilesToProcess and " & _
  159.                             "filtering properties will be processed. For each file that matches the FilesToProcess " & _
  160.                             "property, the UnzipPreprocessingFile event is triggered. That event provides you with " & _
  161.                             "the chance to change the inclusion state of a file, or to change its information " & _
  162.                             "before it is written to the destination unzipping folder."
  163.  
  164.     Public Const cZipSfxHint = "Zip method with self-extracting zip files:" & vbCrLf & _
  165.                                "It's just like creating a regular (non-sfx) zip file, but if you enter a value for " & _
  166.                                "the SfxBinaryModule property, the binary (or any file for that matter) is " & _
  167.                                "prepended to the zip file. The zip file is now self-extracting because " & _
  168.                                "the binary knows how to unzip the rest of the data after itself. Furthermore, if " & _
  169.                                "the library recognises an Xceed binary, it will add config data to the binary so that the " & _
  170.                                "self-extracting zip file can display intro messages and have custom behavior."
  171.  
  172.  
  173. '------------------------------------------------------------------------------------
  174. ' Fills a listbox with possible file attributes
  175. '------------------------------------------------------------------------------------
  176. Public Sub FillAttributeList(lstAttrib As ListBox)
  177.     lstAttrib.Clear
  178.     
  179.     lstAttrib.AddItem "Archive"
  180.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaArchive
  181.     
  182.     lstAttrib.AddItem "Read-Only"
  183.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaReadOnly
  184.     
  185.     lstAttrib.AddItem "Hidden"
  186.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaHidden
  187.     
  188.     lstAttrib.AddItem "System"
  189.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaSystem
  190.     
  191.     lstAttrib.AddItem "Folder"
  192.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaFolder
  193.     
  194.     lstAttrib.AddItem "Volume"
  195.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaVolume
  196.     
  197.     lstAttrib.AddItem "Compressed"
  198.     lstAttrib.ItemData(lstAttrib.ListCount - 1) = xfaCompressed
  199. End Sub
  200.  
  201. '------------------------------------------------------------------------------------
  202. ' This function returns a Long value representing the file attributes checked in
  203. ' a listbox.
  204. '------------------------------------------------------------------------------------
  205. Public Function GetSelectedAttributes(lstAttrib As ListBox) As Long
  206.     Dim lAttrib As Long
  207.     Dim i As Integer
  208.     
  209.     lAttrib = xfaNone
  210.     
  211.     For i = 0 To lstAttrib.ListCount - 1
  212.         If lstAttrib.Selected(i) Then
  213.             lAttrib = lAttrib + lstAttrib.ItemData(i)
  214.         End If
  215.     Next i
  216.     
  217.     GetSelectedAttributes = lAttrib
  218. End Function
  219.  
  220. '------------------------------------------------------------------------------------
  221. ' Initializes a listbox by checking the attributes corresponding to the given
  222. ' attribute mask.
  223. '------------------------------------------------------------------------------------
  224. Public Sub SetSelectedAttributes(lstAttrib As ListBox, xAttrib As xcdFileAttributes)
  225.     Dim i As Integer
  226.     
  227.     For i = 0 To lstAttrib.ListCount - 1
  228.         lstAttrib.Selected(i) = ((lstAttrib.ItemData(i) And xAttrib) > 0)
  229.     Next i
  230. End Sub
  231.  
  232. '------------------------------------------------------------------------------------
  233. ' Sets XceedZip instance with default property values.
  234. '------------------------------------------------------------------------------------
  235. Public Sub SetDefaultProperties(xZip As XceedZip)
  236.   xZip.BasePath = ""
  237.   xZip.CompressionLevel = xclHigh
  238.   xZip.EncryptionPassword = ""
  239.   xZip.RequiredFileAttributes = xfaNone
  240.   xZip.ExcludedFileAttributes = xfaFolder + xfaVolume
  241.   xZip.FilesToProcess = ""
  242.   xZip.FilesToExclude = ""
  243.   xZip.MinDateToProcess = DateSerial(1900, 1, 1)
  244.   xZip.MaxDateToProcess = DateSerial(9999, 12, 31)
  245.   xZip.MinSizeToProcess = 0
  246.   xZip.MaxSizeToProcess = 0      ' Zero means no upper limit
  247.   xZip.SplitSize = 0             ' Zero means no split
  248.   xZip.PreservePaths = True
  249.   xZip.ProcessSubfolders = False
  250.   xZip.SkipIfExisting = False
  251.   xZip.SkipIfNotExisting = False
  252.   xZip.SkipIfOlderDate = False
  253.   xZip.SkipIfOlderVersion = False
  254.   xZip.TempFolder = ""            'Empty means default Windows temp folder
  255.   xZip.UseTempFile = True
  256.   xZip.UnzipToFolder = ""
  257.   xZip.ZipFilename = ""
  258.   xZip.SpanMultipleDisks = xdsRemovableDrivesOnly
  259.   xZip.ExtraHeaders = xehNone
  260. End Sub
  261.